#include <iostream>
#include <vector>
#include <string>
using namespace std;

//            opt(i - 1, j - 1) + 1  s[i] == s[j]
//opt(i, j) = 
//            max(opt(i - 1, j), opt(i, j - 1)) s[1] != s[j]

int cls(string &s1, string s2)
{
        int n = s1.length() - 1;
        int m = s2.length() - 1;
        vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));
        for(int i = 1; i <= n; i++){
                for(int j = 1; j <= m; j++){
                        if(s1[i] == s2[j]){
                                dp[i][j] = dp[i - 1][j - 1] + 1;
                        }else{
                                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
                        }
                }
        }
        return dp.back().back();
}

int main()
{
        string s1, s2;
        while(cin>>s1>>s2){
                s1.insert(0, "0");
                s2.insert(0, "0");
                cout<<cls(s1, s2)<<endl;
        }
        return 0;
}